from openpyxl import load_workbook
from openpyxl.cell.cell import Cell
from openpyxl.workbook.workbook import Workbook
from openpyxl.worksheet.worksheet import Worksheet
import os

inDirPath = "测试文件夹"  # 文件夹路径
files = os.listdir(inDirPath)
for file in files:
    currentWorkbook = load_workbook(file)  # 打开工作簿
    try:  # 异常处理
        currentWorksheet = currentWorkbook.active  # 获取当前活动工作表
        if currentWorksheet is None:  # 如果当前工作表不存在
            raise ValueError("工作表不存在")  # 抛出异常

        ###
        cellA: Cell = currentWorksheet["A1"]  # 获取单元格对象
        valueA = cellA.value  # 获取单元格值
        print(valueA)
        ###

    finally:
        currentWorkbook.close()
